#!/bin/sh
export TZ=UTC-8:00
echo "..........................................mount mmc!" >/dev/console
export LD_LIBRARY_PATH="/lib:/usr/lib:/usr/local/lib"
if [ -d "/mnt/media" ];then
	rm /mnt/media -rf
	mkdir -p /mnt/media
else
	mkdir -p /mnt/media
fi

parted -l /dev/mmcblk0 >/tmp/mmc.info
fstype=`awk -v line=$(awk '/Number/{a=NR+1;print a}' /tmp/mmc.info) 'NR==line' /tmp/mmc.info|awk -F ' ' '{print $6}'`

echo $fstype >/tmp/fsystype

if [ "$fstype" = "fat32" ]
then
        echo $fstype
	if [ -b "/dev/mmcblk0p1" ]
	then
        	echo "file roomInfo.ini is exit"
		mount /dev/mmcblk0p1 /mnt/media/
		/home/record &
		echo "on" >/tmp/isrecord
	else
		mount /dev/mmcblk0 /mnt/media/	
		/home/record &
		echo "on" >/tmp/isrecord
	fi
fi
if [ "$fstype" = "ntfs" ]
then 
	echo $ftype
	if [ -b "/dev/mmcblk0p1" ]
	then
        	ntfs-3g /dev/mmcblk0p1 /mnt/media/
		if [ $? == 0 -a -d "/mnt/media" ]
		then
			echo "mount sucessful"
			echo "on" >/tmp/isrecord
			/home/record &
		fi
		
	else
    		ntfs-3g /dev/mmcblk0 /mnt/media/
		if [ $? == 0 -a -d "/mnt/media"]
		then
			echo "mount sucessful!"
			echo "on" >/tmp/isrecord
			/home/record &
		fi
	fi
fi
echo "...........................mount finished !" >/dev/console
#if [ -d "/mnt/media" ];then                                              
#        /home/record &                            
#else                       
#        killall record
#fi
